package com.coderman.infosys.auth.adapter.controller.system;

import com.coderman.infosys.auth.adapter.controller.BaseController;
import com.coderman.infosys.auth.adapter.convert.SystemConverter;
import com.coderman.infosys.plat.auth.common.dto.ResultDataDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.coderman.infosys.auth.adapter.vo.system.request.UpdateSystemRequestVO;
import com.coderman.infosys.auth.adapter.vo.system.SystemVO;
import com.coderman.infosys.auth.adapter.vo.system.request.CreateSystemRequestVO;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import com.coderman.infosys.auth.domain.bo.system.SystemBO;
import com.coderman.infosys.auth.domain.gataway.SystemModuleQueryGataWay;
import com.coderman.infosys.auth.domain.repository.SystemModuleRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
* @Description:控制层
* @Author:
* @CreateTime:2022-01-04 15:27:39
* @version v1.0
*/
@RestController
public class SystemController extends BaseController {
	
	protected Logger logger = LoggerFactory.getLogger(SystemController.class);

	@Autowired
	private SystemModuleRepository systemModuleRepository;

	/**
	 *
	 * @Description 新建系统信息
	 * @param systemVO
	 * @return SystemVO
	 */
	@RequestMapping(value = "/system/save")
	public ResultDataDto<Boolean> saveSystem(@RequestBody CreateSystemRequestVO systemVO){
        SystemBO systemBO = SystemConverter.INSTANCE.vo2bo(systemVO);
		systemModuleRepository.registSystemMeta(systemBO);
		return  ResultDataDto.success(true);
	}

	/**
	 *
	 * @Description 修改系统信息
	 * @param systemVO
	 * @return Boolean
	 */
	@RequestMapping(value = "/system/update")
	public ResultDataDto<Boolean> updateSystem(@RequestBody UpdateSystemRequestVO systemVO){
        SystemBO systemBO = SystemConverter.INSTANCE.vo2bo(systemVO);
		systemModuleRepository.updateSystemMeta(systemBO);
		return  ResultDataDto.success(true);
	}
}
